/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Interfaz;

import Clases.Mundo;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.ArrayList;
import javax.swing.JFrame;

/**
 *
 * @author Martin
 */
public class Index extends javax.swing.JFrame implements MouseListener, MouseMotionListener {

    public static final int ANCHO = 60;
    public static final int ALTO = 60;

    Mundo mundo;
    ArrayList<GraficoAldea> aldeasParaGrafico;
    ArrayList<String> ordenAldeasVisitadas;
    String ubicacionPirata;
    ArrayList<ArrayList<String>> listaEstados;

    /**
     * Creates new form Index
     */
    public Index(Mundo m) {

        initComponents();
        this.setSize(new Dimension(646, 800));
        this.setResizable(false);
        this.lblArqueologo.setVisible(false);
        this.lblPergamino.setVisible(false);
        this.lblDist.setVisible(false);
        this.lblVal.setVisible(false);
        this.lblDistancia.setVisible(false);
        this.lblValor.setVisible(false);
        this.lblEstado.setVisible(false);
        this.lblAldea.setVisible(false);
        this.lblDistRec1.setVisible(false);
        this.lblDistRec2.setVisible(false);
        this.lblValCar1.setVisible(false);
        this.lblValCar2.setVisible(false);

        this.mundo = m;
        this.aldeasParaGrafico = new ArrayList<GraficoAldea>();
        this.ordenAldeasVisitadas = new ArrayList<String>();
        this.ubicacionPirata = "";
        this.listaEstados = new ArrayList<ArrayList<String>>();

        for (int i = 0; i < mundo.getNombres().size(); i++) {
            String nombre = mundo.getNombres().get(i);

            if ("Ergintone".equals(nombre)) {
                this.aldeasParaGrafico.add(new GraficoAldea(nombre, 299, 181));
            } else {
                if ("Aragaey".equals(nombre)) {
                    this.aldeasParaGrafico.add(new GraficoAldea(nombre, 446, 246));
                } else {
                    if ("Peregaey".equals(nombre)) {
                        this.aldeasParaGrafico.add(new GraficoAldea(nombre, 352, 262));
                    } else {
                        if ("Bulovoe".equals(nombre)) {
                            this.aldeasParaGrafico.add(new GraficoAldea(nombre, 272, 288));
                        } else {
                            if ("Icaedur".equals(nombre)) {
                                this.aldeasParaGrafico.add(new GraficoAldea(nombre, 168, 339));
                            } else {
                                if ("Vinizaile".equals(nombre)) {
                                    this.aldeasParaGrafico.add(new GraficoAldea(nombre, 350, 352));
                                } else {
                                    if ("Bresol".equals(nombre)) {
                                        this.aldeasParaGrafico.add(new GraficoAldea(nombre, 482, 356));
                                    } else {
                                        if ("Cabe".equals(nombre)) {
                                            this.aldeasParaGrafico.add(new GraficoAldea(nombre, 263, 494));
                                        } else {
                                            if ("Mixocu".equals(nombre)) {
                                                this.aldeasParaGrafico.add(new GraficoAldea(nombre, 90, 455));
                                            } else {
                                                if ("Ase".equals(nombre)) {
                                                    this.aldeasParaGrafico.add(new GraficoAldea(nombre, 103, 594));
                                                } else {
                                                    if ("Cenede".equals(nombre)) {
                                                        this.aldeasParaGrafico.add(new GraficoAldea(nombre, 200, 650));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        ArrayList<String> e = new ArrayList<String>();
        e.add("Aragaey");
        e.add("0");
        e.add("0");
        this.agregarEstado(e);

        addMouseListener(this);
        addMouseMotionListener(this);

    }

    public void marcarVisitas(ArrayList<String> v) {
        this.ordenAldeasVisitadas = v;

        for (GraficoAldea aldeasParaGrafico1 : this.aldeasParaGrafico) {
            for (String ordenAldeasVisitada : this.ordenAldeasVisitadas) {
                if (aldeasParaGrafico1.getNombre().equals(ordenAldeasVisitada)) {
                    aldeasParaGrafico1.setVisitada(true);
                }
            }
        }
        this.repaint();
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        this.setExtendedState(JFrame.NORMAL);

        dibujarRutas(g);
        dibujarAldeas(g);
        dibujarAldeasVisitadas(g);
        mostrarCofres();
        quitarPirata();
        mostrarPirata();
    }

    /**
     *
     * Grafica rutas entre las aldeas.
     */
    private void dibujarRutas(Graphics g) {

        Graphics2D g2d = (Graphics2D) g;

        //Grafica el camino recorrido por el arqueologo.
        g2d.setStroke(new BasicStroke(3));
        g2d.setColor(Color.YELLOW);

        if (this.ordenAldeasVisitadas.size() > 1) {
            for (int i = 0; i < this.ordenAldeasVisitadas.size() - 1; i++) {
                int pos = i;
                String origen = this.ordenAldeasVisitadas.get(pos);
                String destino = this.ordenAldeasVisitadas.get(pos + 1);

                g2d.drawLine(this.ubicarAldea(origen).getX() + 10, this.ubicarAldea(origen).getY() + 10,
                        this.ubicarAldea(destino).getX() + 10, this.ubicarAldea(destino).getY() + 10);
            }
        }
    }

    /**
     *
     * Grafica puntos para seÃ±alar las aldeas.
     */
    public void dibujarAldeas(Graphics g) {
        for (GraficoAldea cv : aldeasParaGrafico) {
            if (!cv.visitada) {
                cv.dibujarAldea(g);
            }
        }
    }

    public void dibujarAldeasVisitadas(Graphics g) {
        for (String aldeasVisitada : this.ordenAldeasVisitadas) {
            ubicarAldea(aldeasVisitada).dibujarAldeaVisitada(g);
        }
    }

    public GraficoAldea ubicarAldea(String s) {
        for (GraficoAldea ga : this.aldeasParaGrafico) {
            if (ga.nombre.equals(s)) {
                return ga;
            }
        }
        return null;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        CofreErgintone = new javax.swing.JLabel();
        CofreAragaey = new javax.swing.JLabel();
        CofreBresol = new javax.swing.JLabel();
        CofrePeregaey = new javax.swing.JLabel();
        CofreBulovoe = new javax.swing.JLabel();
        CofreVinizaile = new javax.swing.JLabel();
        CofreIcaedur = new javax.swing.JLabel();
        CofreMixocu = new javax.swing.JLabel();
        CofreCabe = new javax.swing.JLabel();
        CofreCenede = new javax.swing.JLabel();
        CofreAse = new javax.swing.JLabel();
        lblPirataErgintone = new javax.swing.JLabel();
        lblPirataAragaey = new javax.swing.JLabel();
        lblPirataPeregaey = new javax.swing.JLabel();
        lblPirataBresol = new javax.swing.JLabel();
        lblPirataBulovoe = new javax.swing.JLabel();
        lblPirataIcaedur = new javax.swing.JLabel();
        lblPirataVinizaile = new javax.swing.JLabel();
        lblPirataCabe = new javax.swing.JLabel();
        lblPirataMixocu = new javax.swing.JLabel();
        lblPirataAse = new javax.swing.JLabel();
        lblPirataCenede = new javax.swing.JLabel();
        lblAldea = new javax.swing.JLabel();
        lblDistRec1 = new javax.swing.JLabel();
        lblDistRec2 = new javax.swing.JLabel();
        lblValCar1 = new javax.swing.JLabel();
        lblValCar2 = new javax.swing.JLabel();
        lblEstado = new javax.swing.JLabel();
        lblDistancia = new javax.swing.JLabel();
        lblValor = new javax.swing.JLabel();
        lblDist = new javax.swing.JLabel();
        lblVal = new javax.swing.JLabel();
        lblArqueologo = new javax.swing.JLabel();
        lblPergamino = new javax.swing.JLabel();
        lblFondo = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);
        getContentPane().setLayout(null);
        getContentPane().add(CofreErgintone);
        CofreErgintone.setBounds(330, 160, 50, 50);
        CofreErgintone.getAccessibleContext().setAccessibleName("lblCofreErgintone");

        getContentPane().add(CofreAragaey);
        CofreAragaey.setBounds(460, 220, 50, 50);
        CofreAragaey.getAccessibleContext().setAccessibleName("lblCofreAragaey");

        getContentPane().add(CofreBresol);
        CofreBresol.setBounds(520, 330, 50, 50);
        CofreBresol.getAccessibleContext().setAccessibleName("lblCofreBresol");

        getContentPane().add(CofrePeregaey);
        CofrePeregaey.setBounds(370, 250, 50, 50);
        CofrePeregaey.getAccessibleContext().setAccessibleName("lblCofrePeregaey");

        getContentPane().add(CofreBulovoe);
        CofreBulovoe.setBounds(280, 270, 50, 50);
        CofreBulovoe.getAccessibleContext().setAccessibleName("lblCofreBulovoe");

        getContentPane().add(CofreVinizaile);
        CofreVinizaile.setBounds(360, 330, 50, 50);
        CofreVinizaile.getAccessibleContext().setAccessibleName("lblCofreVinizaile");

        getContentPane().add(CofreIcaedur);
        CofreIcaedur.setBounds(140, 330, 50, 50);
        CofreIcaedur.getAccessibleContext().setAccessibleName("lblCofreIcaedur");

        getContentPane().add(CofreMixocu);
        CofreMixocu.setBounds(110, 470, 50, 50);
        CofreMixocu.getAccessibleContext().setAccessibleName("lblCofreMixocu");

        getContentPane().add(CofreCabe);
        CofreCabe.setBounds(250, 490, 50, 50);
        CofreCabe.getAccessibleContext().setAccessibleName("lblCofreCabe");

        getContentPane().add(CofreCenede);
        CofreCenede.setBounds(220, 620, 50, 50);
        CofreCenede.getAccessibleContext().setAccessibleName("lblCofreCenede");

        getContentPane().add(CofreAse);
        CofreAse.setBounds(80, 590, 50, 50);
        CofreAse.getAccessibleContext().setAccessibleName("lblCofreAse");

        getContentPane().add(lblPirataErgintone);
        lblPirataErgintone.setBounds(260, 110, 60, 60);
        lblPirataErgintone.getAccessibleContext().setAccessibleName("lblPirataErgintone");

        lblPirataAragaey.setFocusable(false);
        getContentPane().add(lblPirataAragaey);
        lblPirataAragaey.setBounds(400, 170, 60, 60);
        getContentPane().add(lblPirataPeregaey);
        lblPirataPeregaey.setBounds(340, 190, 80, 90);
        getContentPane().add(lblPirataBresol);
        lblPirataBresol.setBounds(440, 280, 60, 60);
        getContentPane().add(lblPirataBulovoe);
        lblPirataBulovoe.setBounds(220, 220, 60, 60);
        getContentPane().add(lblPirataIcaedur);
        lblPirataIcaedur.setBounds(120, 260, 60, 60);
        getContentPane().add(lblPirataVinizaile);
        lblPirataVinizaile.setBounds(310, 280, 60, 60);
        getContentPane().add(lblPirataCabe);
        lblPirataCabe.setBounds(220, 400, 60, 60);
        getContentPane().add(lblPirataMixocu);
        lblPirataMixocu.setBounds(50, 380, 60, 60);
        getContentPane().add(lblPirataAse);
        lblPirataAse.setBounds(50, 520, 60, 60);
        getContentPane().add(lblPirataCenede);
        lblPirataCenede.setBounds(170, 570, 60, 60);
        getContentPane().add(lblAldea);
        lblAldea.setBounds(30, 30, 160, 20);

        lblDistRec1.setText("Distancia Recorrida:");
        getContentPane().add(lblDistRec1);
        lblDistRec1.setBounds(30, 60, 130, 20);
        getContentPane().add(lblDistRec2);
        lblDistRec2.setBounds(30, 80, 160, 20);

        lblValCar1.setText("Valor del tesoro cargado:");
        getContentPane().add(lblValCar1);
        lblValCar1.setBounds(30, 100, 160, 20);
        getContentPane().add(lblValCar2);
        lblValCar2.setBounds(30, 120, 160, 20);

        lblEstado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/PergaminoGrande.png"))); // NOI18N
        getContentPane().add(lblEstado);
        lblEstado.setBounds(10, 10, 220, 150);
        lblEstado.getAccessibleContext().setAccessibleName("");

        getContentPane().add(lblDistancia);
        lblDistancia.setBounds(480, 500, 110, 20);
        getContentPane().add(lblValor);
        lblValor.setBounds(480, 550, 120, 20);

        lblDist.setText("DISTANCIA TOTAL:");
        getContentPane().add(lblDist);
        lblDist.setBounds(480, 480, 120, 20);

        lblVal.setText("VALOR TOTAL:");
        getContentPane().add(lblVal);
        lblVal.setBounds(480, 530, 120, 14);

        lblArqueologo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Arqueologo.png"))); // NOI18N
        getContentPane().add(lblArqueologo);
        lblArqueologo.setBounds(410, 520, 100, 120);

        lblPergamino.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pergamino.png"))); // NOI18N
        getContentPane().add(lblPergamino);
        lblPergamino.setBounds(460, 470, 170, 120);

        lblFondo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/MapaOriginal.png"))); // NOI18N
        lblFondo.setText("jLabel4");
        getContentPane().add(lblFondo);
        lblFondo.setBounds(0, 0, 630, 780);
        lblFondo.getAccessibleContext().setAccessibleName("lblFondo");

        pack();
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel CofreAragaey;
    private javax.swing.JLabel CofreAse;
    private javax.swing.JLabel CofreBresol;
    private javax.swing.JLabel CofreBulovoe;
    private javax.swing.JLabel CofreCabe;
    private javax.swing.JLabel CofreCenede;
    private javax.swing.JLabel CofreErgintone;
    private javax.swing.JLabel CofreIcaedur;
    private javax.swing.JLabel CofreMixocu;
    private javax.swing.JLabel CofrePeregaey;
    private javax.swing.JLabel CofreVinizaile;
    private javax.swing.JLabel lblAldea;
    private javax.swing.JLabel lblArqueologo;
    private javax.swing.JLabel lblDist;
    private javax.swing.JLabel lblDistRec1;
    private javax.swing.JLabel lblDistRec2;
    private javax.swing.JLabel lblDistancia;
    private javax.swing.JLabel lblEstado;
    private javax.swing.JLabel lblFondo;
    private javax.swing.JLabel lblPergamino;
    private javax.swing.JLabel lblPirataAragaey;
    private javax.swing.JLabel lblPirataAse;
    private javax.swing.JLabel lblPirataBresol;
    private javax.swing.JLabel lblPirataBulovoe;
    private javax.swing.JLabel lblPirataCabe;
    private javax.swing.JLabel lblPirataCenede;
    private javax.swing.JLabel lblPirataErgintone;
    private javax.swing.JLabel lblPirataIcaedur;
    private javax.swing.JLabel lblPirataMixocu;
    private javax.swing.JLabel lblPirataPeregaey;
    private javax.swing.JLabel lblPirataVinizaile;
    private javax.swing.JLabel lblVal;
    private javax.swing.JLabel lblValCar1;
    private javax.swing.JLabel lblValCar2;
    private javax.swing.JLabel lblValor;
    // End of variables declaration//GEN-END:variables

    private void mostrarCofres() {
        if (mundo.getCofre("Aragaey") == null) {
            this.CofreAragaey.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreVacio.png")));
        } else {
            this.CofreAragaey.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreLleno.png")));
        }
        if (mundo.getCofre("Ase") == null) {
            this.CofreAse.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreVacio.png")));
        } else {
            this.CofreAse.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreLleno.png")));
        }
        if (mundo.getCofre("Bresol") == null) {
            this.CofreBresol.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreVacio.png")));
        } else {
            this.CofreBresol.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreLleno.png")));
        }
        if (mundo.getCofre("Bulovoe") == null) {
            this.CofreBulovoe.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreVacio.png")));
        } else {
            this.CofreBulovoe.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreLleno.png")));
        }
        if (mundo.getCofre("Cabe") == null) {
            this.CofreCabe.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreVacio.png")));
        } else {
            this.CofreCabe.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreLleno.png")));
        }
        if (mundo.getCofre("Cenede") == null) {
            this.CofreCenede.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreVacio.png")));
        } else {
            this.CofreCenede.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreLleno.png")));
        }
        if (mundo.getCofre("Ergintone") == null) {
            this.CofreErgintone.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreVacio.png")));
        } else {
            this.CofreErgintone.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreLleno.png")));
        }
        if (mundo.getCofre("Icaedur") == null) {
            this.CofreIcaedur.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreVacio.png")));
        } else {
            this.CofreIcaedur.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreLleno.png")));
        }
        if (mundo.getCofre("Mixocu") == null) {
            this.CofreMixocu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreVacio.png")));
        } else {
            this.CofreMixocu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreLleno.png")));
        }
        if (mundo.getCofre("Peregaey") == null) {
            this.CofrePeregaey.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreVacio.png")));
        } else {
            this.CofrePeregaey.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreLleno.png")));
        }
        if (mundo.getCofre("Vinizaile") == null) {
            this.CofreVinizaile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreVacio.png")));
        } else {
            this.CofreVinizaile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/CofreLleno.png")));
        }
    }

    public void mostrarPirata() {

        if (this.ubicacionPirata.equals("Aragaey")) {
            this.lblPirataAragaey.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pirata.png")));
        } else {
            if (this.ubicacionPirata.equals("Ase")) {
                this.lblPirataAse.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pirata.png")));
            } else {
                if (this.ubicacionPirata.equals("Bresol")) {
                    this.lblPirataBresol.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pirata.png")));
                } else {
                    if (this.ubicacionPirata.equals("Bulovoe")) {
                        this.lblPirataBulovoe.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pirata.png")));
                    } else {
                        if (this.ubicacionPirata.equals("Cabe")) {
                            this.lblPirataCabe.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pirata.png")));
                        } else {
                            if (this.ubicacionPirata.equals("Cabe")) {
                                this.lblPirataCabe.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pirata.png")));
                            } else {
                                if (this.ubicacionPirata.equals("Cenede")) {
                                    this.lblPirataCenede.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pirata.png")));
                                } else {
                                    if (this.ubicacionPirata.equals("Ergintone")) {
                                        this.lblPirataErgintone.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pirata.png")));
                                    } else {
                                        if (this.ubicacionPirata.equals("Icaedur")) {
                                            this.lblPirataIcaedur.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pirata.png")));
                                        } else {
                                            if (this.ubicacionPirata.equals("Icaedur")) {
                                                this.lblPirataIcaedur.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pirata.png")));
                                            } else {
                                                if (this.ubicacionPirata.equals("Icaedur")) {
                                                    this.lblPirataIcaedur.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pirata.png")));
                                                } else {
                                                    if (this.ubicacionPirata.equals("Mixocu")) {
                                                        this.lblPirataMixocu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pirata.png")));
                                                    } else {
                                                        if (this.ubicacionPirata.equals("Peregaey")) {
                                                            this.lblPirataPeregaey.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pirata.png")));
                                                        } else {
                                                            if (this.ubicacionPirata.equals("Vinizaile")) {
                                                                this.lblPirataVinizaile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/Pirata.png")));
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    public void quitarPirata() {
        this.lblPirataAragaey.setIcon(null);
        this.lblPirataAse.setIcon(null);
        this.lblPirataBresol.setIcon(null);
        this.lblPirataBulovoe.setIcon(null);
        this.lblPirataCabe.setIcon(null);
        this.lblPirataCenede.setIcon(null);
        this.lblPirataErgintone.setIcon(null);
        this.lblPirataIcaedur.setIcon(null);
        this.lblPirataMixocu.setIcon(null);
        this.lblPirataPeregaey.setIcon(null);
        this.lblPirataVinizaile.setIcon(null);
    }

    public void setUbicacionPirata(String posicion) {
        this.ubicacionPirata = posicion;
        this.repaint();
    }

    public void mouseClicked(MouseEvent me) {
        if (me.getX() >= this.ubicarAldea("Aragaey").getX() && me.getX() <= (this.ubicarAldea("Aragaey").getX() + this.ANCHO)
                && me.getY() >= this.ubicarAldea("Aragaey").getY() && me.getY() <= (this.ubicarAldea("Aragaey").getY() + this.ALTO)) {
            if (this.ubicarAldea("Aragaey").fueVisitada()) {
                this.imprimirEstado("Aragaey");
            }
        }
        if (me.getX() >= this.ubicarAldea("Ergintone").getX() && me.getX() <= (this.ubicarAldea("Ergintone").getX() + this.ANCHO)
                && me.getY() >= this.ubicarAldea("Ergintone").getY() && me.getY() <= (this.ubicarAldea("Ergintone").getY() + this.ALTO)) {
            if (this.ubicarAldea("Ergintone").fueVisitada()) {
                this.imprimirEstado("Ergintone");
            }
        }
        if (me.getX() >= this.ubicarAldea("Peregaey").getX() && me.getX() <= (this.ubicarAldea("Peregaey").getX() + this.ANCHO)
                && me.getY() >= this.ubicarAldea("Peregaey").getY() && me.getY() <= (this.ubicarAldea("Peregaey").getY() + this.ALTO)) {
            if (this.ubicarAldea("Peregaey").fueVisitada()) {
                this.imprimirEstado("Peregaey");
            }
        }
        if (me.getX() >= this.ubicarAldea("Bulovoe").getX() && me.getX() <= (this.ubicarAldea("Bulovoe").getX() + this.ANCHO)
                && me.getY() >= this.ubicarAldea("Bulovoe").getY() && me.getY() <= (this.ubicarAldea("Bulovoe").getY() + this.ALTO)) {
            if (this.ubicarAldea("Bulovoe").fueVisitada()) {
                this.imprimirEstado("Bulovoe");
            }
        }
        if (me.getX() >= this.ubicarAldea("Icaedur").getX() && me.getX() <= (this.ubicarAldea("Icaedur").getX() + this.ANCHO)
                && me.getY() >= this.ubicarAldea("Icaedur").getY() && me.getY() <= (this.ubicarAldea("Icaedur").getY() + this.ALTO)) {
            if (this.ubicarAldea("Icaedur").fueVisitada()) {
                this.imprimirEstado("Icaedur");
            }
        }
        if (me.getX() >= this.ubicarAldea("Vinizaile").getX() && me.getX() <= (this.ubicarAldea("Vinizaile").getX() + this.ANCHO)
                && me.getY() >= this.ubicarAldea("Vinizaile").getY() && me.getY() <= (this.ubicarAldea("Vinizaile").getY() + this.ALTO)) {
            if (this.ubicarAldea("Vinizaile").fueVisitada()) {
                this.imprimirEstado("Vinizaile");
            }
        }
        if (me.getX() >= this.ubicarAldea("Bresol").getX() && me.getX() <= (this.ubicarAldea("Bresol").getX() + this.ANCHO)
                && me.getY() >= this.ubicarAldea("Bresol").getY() && me.getY() <= (this.ubicarAldea("Bresol").getY() + this.ALTO)) {
            if (this.ubicarAldea("Bresol").fueVisitada()) {
                this.imprimirEstado("Bresol");
            }
        }
        if (me.getX() >= this.ubicarAldea("Cabe").getX() && me.getX() <= (this.ubicarAldea("Cabe").getX() + this.ANCHO)
                && me.getY() >= this.ubicarAldea("Cabe").getY() && me.getY() <= (this.ubicarAldea("Cabe").getY() + this.ALTO)) {
            if (this.ubicarAldea("Cabe").fueVisitada()) {
                this.imprimirEstado("Cabe");
            }
        }
        if (me.getX() >= this.ubicarAldea("Mixocu").getX() && me.getX() <= (this.ubicarAldea("Mixocu").getX() + this.ANCHO)
                && me.getY() >= this.ubicarAldea("Mixocu").getY() && me.getY() <= (this.ubicarAldea("Mixocu").getY() + this.ALTO)) {
            if (this.ubicarAldea("Mixocu").fueVisitada()) {
                this.imprimirEstado("Mixocu");
            }
        }
        if (me.getX() >= this.ubicarAldea("Ase").getX() && me.getX() <= (this.ubicarAldea("Ase").getX() + this.ANCHO)
                && me.getY() >= this.ubicarAldea("Ase").getY() && me.getY() <= (this.ubicarAldea("Ase").getY() + this.ALTO)) {
            if (this.ubicarAldea("Ase").fueVisitada()) {
                this.imprimirEstado("Ase");
            }
        }
        if (me.getX() >= this.ubicarAldea("Cenede").getX() && me.getX() <= (this.ubicarAldea("Cenede").getX() + this.ANCHO)
                && me.getY() >= this.ubicarAldea("Cenede").getY() && me.getY() <= (this.ubicarAldea("Cenede").getY() + this.ALTO)) {
            if (this.ubicarAldea("Cenede").fueVisitada()) {
                this.imprimirEstado("Cenede");
            }
        }

    }

    public void mousePressed(MouseEvent me) {
    }

    public void mouseReleased(MouseEvent me) {
    }

    public void mouseEntered(MouseEvent me) {
    }

    public void mouseExited(MouseEvent me) {
    }

    public void mouseDragged(MouseEvent me) {
    }

    public void mouseMoved(MouseEvent me) {
    }

    public boolean agregarEstado(ArrayList<String> e) {
        for (int i = 0; i < this.listaEstados.size(); i++) {
            if (this.listaEstados.get(i).get(0) == e.get(0)) {
                return false;
            }
        }
        this.listaEstados.add(e);
        return true;
    }

    public void imprimirEstado(String a) {
        this.lblAldea.setVisible(true);
        this.lblDistRec1.setVisible(true);
        this.lblDistRec2.setVisible(true);
        this.lblValCar1.setVisible(true);
        this.lblValCar2.setVisible(true);

        for (ArrayList<String> listaEstado : this.listaEstados) {
            if (listaEstado.get(0).equals(a)) {
                this.lblAldea.setText("Aldea " + listaEstado.get(0));
                this.lblDistRec2.setText(" " + listaEstado.get(1) + " km");
                this.lblValCar2.setText(" $ " + listaEstado.get(2));
            }
        }
    }

    public void visualizarEstadoFinal(int d, int v) {
        this.lblEstado.setVisible(true);
        this.lblDistancia.setText("" + d);
        this.lblValor.setText("" + v);
        this.lblArqueologo.setVisible(true);
        this.lblPergamino.setVisible(true);
        this.lblDist.setVisible(true);
        this.lblVal.setVisible(true);
        this.lblDistancia.setVisible(true);
        this.lblValor.setVisible(true);
    }
}
